package com.example.weibo_app.controller;


import com.example.weibo_app.common.utils.AjaxResult;
import com.example.weibo_app.domain.Favorite;
import com.example.weibo_app.service.FavoriteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags = "用户收藏管理")
public class FavoriteController {

    @Autowired
    private FavoriteService favoriteService;

    @PostMapping("/favorites")
    @ApiOperation(value = "添加收藏")
    public AjaxResult addFavorite(@RequestBody Favorite favorite) {
        return AjaxResult.success(favoriteService.addFavorite(favorite));
    }

    @DeleteMapping("/favorites")
    @ApiOperation(value = "删除收藏")
    public AjaxResult removeFavorite(@RequestBody Favorite favorite) {
        return AjaxResult.success(favoriteService.removeFavorite(favorite));
    }
}
